package com.ww.springboot.boot.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("blade.lock")
public class BladeLockProperties {
    public static final String PREFIX = "blade.lock";
    private Boolean enabled;
    private String address;
    private String password;
    private Integer database;
    private Integer poolSize;
    private Integer idleSize;
    private Integer idleTimeout;
    private Integer connectionTimeout;
    private Integer timeout;
    private BladeLockProperties.Mode mode;
    private String masterAddress;
    private String[] slaveAddress;
    private String masterName;
    private String[] sentinelAddress;
    private String[] nodeAddress;

    public BladeLockProperties() {
        this.enabled = Boolean.FALSE;
        this.address = "redis://127.0.0.1:6379";
        this.database = 0;
        this.poolSize = 20;
        this.idleSize = 5;
        this.idleTimeout = 60000;
        this.connectionTimeout = 3000;
        this.timeout = 10000;
        this.mode = BladeLockProperties.Mode.single;
    }

    public Boolean getEnabled() {
        return this.enabled;
    }

    public String getAddress() {
        return this.address;
    }

    public String getPassword() {
        return this.password;
    }

    public Integer getDatabase() {
        return this.database;
    }

    public Integer getPoolSize() {
        return this.poolSize;
    }

    public Integer getIdleSize() {
        return this.idleSize;
    }

    public Integer getIdleTimeout() {
        return this.idleTimeout;
    }

    public Integer getConnectionTimeout() {
        return this.connectionTimeout;
    }

    public Integer getTimeout() {
        return this.timeout;
    }

    public BladeLockProperties.Mode getMode() {
        return this.mode;
    }

    public String getMasterAddress() {
        return this.masterAddress;
    }

    public String[] getSlaveAddress() {
        return this.slaveAddress;
    }

    public String getMasterName() {
        return this.masterName;
    }

    public String[] getSentinelAddress() {
        return this.sentinelAddress;
    }

    public String[] getNodeAddress() {
        return this.nodeAddress;
    }

    public void setEnabled(final Boolean enabled) {
        this.enabled = enabled;
    }

    public void setAddress(final String address) {
        this.address = address;
    }

    public void setPassword(final String password) {
        this.password = password;
    }

    public void setDatabase(final Integer database) {
        this.database = database;
    }

    public void setPoolSize(final Integer poolSize) {
        this.poolSize = poolSize;
    }

    public void setIdleSize(final Integer idleSize) {
        this.idleSize = idleSize;
    }

    public void setIdleTimeout(final Integer idleTimeout) {
        this.idleTimeout = idleTimeout;
    }

    public void setConnectionTimeout(final Integer connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
    }

    public void setTimeout(final Integer timeout) {
        this.timeout = timeout;
    }

    public void setMode(final BladeLockProperties.Mode mode) {
        this.mode = mode;
    }

    public void setMasterAddress(final String masterAddress) {
        this.masterAddress = masterAddress;
    }

    public void setSlaveAddress(final String[] slaveAddress) {
        this.slaveAddress = slaveAddress;
    }

    public void setMasterName(final String masterName) {
        this.masterName = masterName;
    }

    public void setSentinelAddress(final String[] sentinelAddress) {
        this.sentinelAddress = sentinelAddress;
    }

    public void setNodeAddress(final String[] nodeAddress) {
        this.nodeAddress = nodeAddress;
    }

    public static enum Mode {
        single,
        master,
        sentinel,
        cluster;

        private Mode() {
        }
    }
}